package cn.edu.sdjzu.xg.bysj.exception;
//http://www.zhaojun.im/springboot-exception/
import java.util.Collection;

public class ResultBean<T> {
    //响应代号
    private int code;
    //响应说明
    private String message;
    //响应数据
    private Collection<T> data;

    private ResultBean() {

    }

    public ResultBean(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultBean(int code, String message, Collection<T> data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
//
//    //请求未成功执行
//    public static ResultBean error(int code, String message) {
//        ResultBean resultBean = new ResultBean();
//        resultBean.setCode(code);
//        resultBean.setMessage(message);
//        return resultBean;
//    }
//    //请求成功执行，但无数据返回
//    public static ResultBean success() {
//        ResultBean resultBean = new ResultBean();
//        resultBean.setCode(0);
//        resultBean.setMessage("success");
//        return resultBean;
//    }
//    //请求成功执行且有数据返回
//    public static <V> ResultBean<V> success(Collection<V> data) {
//        ResultBean resultBean = new ResultBean();
//        resultBean.setCode(0);
//        resultBean.setMessage("success");
//        resultBean.setData(data);
//        return resultBean;
//    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Collection<T> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResultBean{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
